package com.ai.sys.http;

import java.io.IOException;
import java.util.Map;

import com.ai.tool.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.sun.net.httpserver.HttpExchange;

public class HttpDataHandler extends AbstractHandler {

	/**
	 * 文件接收
	 */
	public void handle(HttpExchange httpExchange) {
		Map<String, String> res = buildResult();
		try {
			JSONObject json = getReqJson(httpExchange);

			String action = json.getString("action");// 操作
			String dev = json.getString("dev");// 设备类型

			String fileName = getAttPram(httpExchange, "fileName");
			fileName = FileUtil.asciiToString(fileName);

		} catch (Exception e) {
			res.put("result", "401");
			res.put("message", "失败");
			e.printStackTrace();
		} finally {
			try {
				sendResponse(httpExchange, res);
			} catch (IOException e) {
				e.printStackTrace();
			}
			httpExchange.close();
		}
	}

}
